package graphlib;

import dk.itu.KrakMap.*;
import java.io.*;
import java.util.*;

/**
 *
 * @author KF04-ITU-2011, Group 11
 */
public class SampleGraph {
    private HashMap<String, KrakNode> nodes = new HashMap<String,KrakNode>();
    private HashMap<String, KrakEdge> edges = new HashMap<String, KrakEdge>();
    private Graph<KrakEdge, KrakNode> graph;
    private int nodeCount = 0;

    public SampleGraph() throws IOException{
       nodes.put("A", kn(8.63,96.73));
       nodes.put("B", kn(0,80));
       nodes.put("C", kn(11.59,85.34));
       nodes.put("D", kn(19.8,88.3));
       nodes.put("E", kn(29.59,91.49));
       nodes.put("F", kn(39.39,85.34));
       nodes.put("G", kn(45.99,92.4));
       nodes.put("H", kn(51.01,99.01));
       nodes.put("I", kn(57.16,94.45));
       nodes.put("J", kn(52.6,88.3));
       nodes.put("K", kn(47.13,80.56));
       nodes.put("L", kn(29.14,85.8));
       nodes.put("M", kn(24.12,83.29));
       nodes.put("N", kn(13.42,71.67));
       nodes.put("O", kn(13.19,54.59));
       nodes.put("P", kn(23.44,57.78));
       nodes.put("Q", kn(19.11,27.48));
       nodes.put("R", kn(36.43,34.31));
       nodes.put("S", kn(37.34,41.83));
       nodes.put("T", kn(42.8,42.97));
       nodes.put("U", kn(49.41,39.78));
       nodes.put("V", kn(52.6,13.81));
       nodes.put("W", kn(12.28,110.86));
       nodes.put("Y", kn(57.38,16.54));
       nodes.put("X", kn(65.81,54.36));
       nodes.put("Z", kn(80,60));
       nodes.put("AA", kn(90.42,69.85));
       nodes.put("AB", kn(76.98,41.15));
       nodes.put("AC", kn(88.14,48.66));
       nodes.put("AD", kn(87.23,29.76));
       nodes.put("AE", kn(98.52,37.5));
       nodes.put("AF", kn(108.41,50.71));
       nodes.put("AG", kn(91.43,22.69));
       nodes.put("AH", kn(104.09,30.44));
       nodes.put("AI", kn(59.89,63.47));
       nodes.put("AJ", kn(67.64,75.32));
       nodes.put("AK", kn(19.8,110.86));
       nodes.put("AL", kn(63.08,-4.42));
       nodes.put("AM", kn(69.69,-3.51));

       edges.put("a", new KrakEdge(getNodes().get("A"), getNodes().get("C"), RoadType.Vej, Edge.BOTH));
       edges.put("a1", new KrakEdge(getNodes().get("F"), getNodes().get("G"), RoadType.Vej, Edge.BOTH));
       edges.put("a2", new KrakEdge(getNodes().get("AE"), getNodes().get("AF"), RoadType.Vej, Edge.BOTH));
       edges.put("b", new KrakEdge(getNodes().get("B"), getNodes().get("C"), RoadType.Vej, Edge.BOTH));
       edges.put("b1", new KrakEdge(getNodes().get("G"), getNodes().get("H"), RoadType.Vej, Edge.BOTH));
       edges.put("b2", new KrakEdge(getNodes().get("AA"), getNodes().get("AF"), RoadType.Vej, Edge.BOTH));
       edges.put("c", new KrakEdge(getNodes().get("C"), getNodes().get("N"), RoadType.Vej, Edge.BOTH));
       edges.put("c1", new KrakEdge(getNodes().get("H"), getNodes().get("I"), RoadType.Vej, Edge.BOTH));
       edges.put("c2", new KrakEdge(getNodes().get("AJ"), getNodes().get("AA"), RoadType.Vej, Edge.BOTH));
       edges.put("d", new KrakEdge(getNodes().get("N"), getNodes().get("O"), RoadType.Vej, Edge.BOTH));
       edges.put("d1", new KrakEdge(getNodes().get("G"), getNodes().get("J"), RoadType.Vej, Edge.BOTH));
       edges.put("d2", new KrakEdge(getNodes().get("Y"), getNodes().get("Z"), RoadType.Primaerrute, Edge.BOTH));
       edges.put("e", new KrakEdge(getNodes().get("N"), getNodes().get("P"), RoadType.Vej, Edge.BOTH));
       edges.put("e1", new KrakEdge(getNodes().get("F"), getNodes().get("K"), RoadType.Vej, Edge.BOTH));
       edges.put("e2", new KrakEdge(getNodes().get("Z"), getNodes().get("AA"), RoadType.Primaerrute, Edge.BOTH));
       edges.put("f", new KrakEdge(getNodes().get("O"), getNodes().get("Q"), RoadType.Vej, Edge.BOTH));
       edges.put("f1", new KrakEdge(getNodes().get("K"), getNodes().get("J"), RoadType.Vej, Edge.BOTH));
       edges.put("f2", new KrakEdge(getNodes().get("Z"), getNodes().get("AC"), RoadType.Vej, Edge.BOTH));
       edges.put("g", new KrakEdge(getNodes().get("Q"), getNodes().get("R"), RoadType.Primaerrute, Edge.BOTH));
       edges.put("g1", new KrakEdge(getNodes().get("J"), getNodes().get("I"), RoadType.Vej, Edge.BOTH));
       edges.put("g2", new KrakEdge(getNodes().get("U"), getNodes().get("Y"), RoadType.Primaerrute, Edge.BOTH));
       edges.put("h", new KrakEdge(getNodes().get("S"), getNodes().get("R"), RoadType.Motorvejsafkorsel, Edge.FORWARD));
       edges.put("h1", new KrakEdge(getNodes().get("J"), getNodes().get("AJ"), RoadType.Vej, Edge.BOTH));
       edges.put("h2", new KrakEdge(getNodes().get("W"), getNodes().get("M"), RoadType.MOTORVEJ, Edge.FORWARD));
       edges.put("i", new KrakEdge(getNodes().get("R"), getNodes().get("U"), RoadType.Primaerrute, Edge.BOTH));
       edges.put("i1", new KrakEdge(getNodes().get("I"), getNodes().get("AA"), RoadType.Vej, Edge.BOTH));
       edges.put("i2", new KrakEdge(getNodes().get("L"), getNodes().get("AK"), RoadType.MOTORVEJ, Edge.FORWARD));
       edges.put("j", new KrakEdge(getNodes().get("U"), getNodes().get("T"), RoadType.Motortrafikvejsafkorsel, Edge.FORWARD));
       edges.put("j1", new KrakEdge(getNodes().get("K"), getNodes().get("AI"), RoadType.Vej, Edge.BOTH));
       edges.put("j2", new KrakEdge(getNodes().get("V"), getNodes().get("AL"), RoadType.MOTORVEJ, Edge.FORWARD));
       edges.put("k", new KrakEdge(getNodes().get("S"), getNodes().get("V"), RoadType.MOTORVEJ, Edge.FORWARD));
       edges.put("k1", new KrakEdge(getNodes().get("AI"), getNodes().get("Y"), RoadType.Vej, Edge.BOTH));
       edges.put("k2", new KrakEdge(getNodes().get("AM"), getNodes().get("X"), RoadType.MOTORVEJ, Edge.FORWARD));
       edges.put("l", new KrakEdge(getNodes().get("X"), getNodes().get("T"), RoadType.MOTORVEJ, Edge.FORWARD));
       edges.put("l1", new KrakEdge(getNodes().get("Y"), getNodes().get("AB"), RoadType.Vej, Edge.BOTH));
       edges.put("m", new KrakEdge(getNodes().get("T"), getNodes().get("L"), RoadType.MOTORVEJ, Edge.FORWARD));
       edges.put("m1", new KrakEdge(getNodes().get("AD"), getNodes().get("AB"), RoadType.Vej, Edge.BOTH));
       edges.put("n", new KrakEdge(getNodes().get("L"), getNodes().get("E"), RoadType.Motorvejsafkorsel, Edge.FORWARD));
       edges.put("n1", new KrakEdge(getNodes().get("AD"), getNodes().get("AG"), RoadType.Vej, Edge.BOTH));
       edges.put("p", new KrakEdge(getNodes().get("D"), getNodes().get("M"), RoadType.Motorvejsafkorsel, Edge.FORWARD));
       edges.put("p1", new KrakEdge(getNodes().get("AG"), getNodes().get("AH"), RoadType.Vej, Edge.BOTH));
       edges.put("q", new KrakEdge(getNodes().get("M"), getNodes().get("S"), RoadType.MOTORVEJ, Edge.FORWARD));
       edges.put("q1", new KrakEdge(getNodes().get("AE"), getNodes().get("AH"), RoadType.Vej, Edge.BOTH));
       edges.put("r", new KrakEdge(getNodes().get("C"), getNodes().get("D"), RoadType.Vej, Edge.BOTH));
       edges.put("r1", new KrakEdge(getNodes().get("AD"), getNodes().get("AE"), RoadType.Vej, Edge.BOTH));
       edges.put("s", new KrakEdge(getNodes().get("D"), getNodes().get("E"), RoadType.Vej, Edge.BOTH));
       edges.put("s1", new KrakEdge(getNodes().get("AB"), getNodes().get("AC"), RoadType.Vej, Edge.BOTH));
       edges.put("t", new KrakEdge(getNodes().get("E"), getNodes().get("F"), RoadType.Vej, Edge.BOTH));
       edges.put("t1", new KrakEdge(getNodes().get("AC"), getNodes().get("AE"), RoadType.Vej, Edge.BOTH));

       ArrayList<KrakNode> tempNodes = new ArrayList<KrakNode>();
       tempNodes.addAll(nodes.values());
       graph = new Graph(tempNodes);

       ArrayList<KrakEdge> tempEdges = new ArrayList<KrakEdge>();
       tempEdges.addAll(edges.values());
       graph.addEdges(tempEdges);
    }

    private KrakNode kn(double x, double y) throws IOException{
        nodeCount++;
        return new KrakNode(new NodeData("0,"+(getNodeCount()-1)+","+(getNodeCount()-1)+","+x+"," + y));
    }

    /**
     * @return the nodes
     */
    public HashMap<String, KrakNode> getNodes()
    {
        return nodes;
    }

    /**
     * @return the edges
     */
    public HashMap<String, KrakEdge> getEdges()
    {
        return edges;
    }

    /**
     * @return the graph
     */
    public Graph<KrakEdge, KrakNode> getGraph()
    {
        return graph;
    }

    /**
     * @return the nodeCount
     */
    public int getNodeCount()
    {
        return nodeCount;
    }
}
